<?php
if (arg(0) == 'member' && is_numeric(arg(1))) {
  $account = user_load(arg(1));
} else {
  global $user;
  $account = user_load($user->uid);
}

?>
<div id="customer_profile">
<div class="wrap_960">
  <?php if (!$data['user_is_not_exists']) { ?>
  <div id="customer_profile_top">
    <div class="customer_profile_left">
      <div id="customer_profile_about">
        <?php if (empty($account->picture)) : ?>
        <p id="no-avatar"><img width="150" height="150"
                               src="<?php echo base_path() . 'sites/all/modules/tvn_modules/'?>tvn_common/images/no_avatar2.jpg"
                               alt=""/>
          <?php if (arg(0) != 'member'): ?><a class="avatar_change" href="javascript:;">upload avatar</a><?php endif;?>
        </p>
        <?php else : ?>
        <p id="avatar"><img width="150" height="150"
                            src="<?php echo  image_style_url('avartar', $account->picture->uri) ?>"
                            alt=""/><?php if (arg(0) != 'member'): ?><a class="avatar_change" href="javascript:;">change
          avatar</a><?php endif;?></p>

        <?php endif; ?>
        <div id="account_detail">
          <h3><?php echo t('Account Details');?></h3>
          <?php if (arg(0) == 'member'): ?>
          <span><a href="javascript:;" <?php echo ($data['following']) ? '':"id ='following_user' id_follow= '".arg(1)."'";?> title=""><?php echo ($data['following']) ? t('Following'):t('Follow');?></a></span>
          <?php else: ?>
          <span>3 <?php echo t('Credits Left');?></span><span><a href=""
                                                                 title=""><?php echo t('Buy More...');?></a></span>
          <?php endif;?>

        </div>
      </div>
    </div>

    <div class="customer_profile_right">
      <div id="customer_profile_info">
        <div id="account_information">
          <h3
            id='customer_name'><?php echo $account->field_customer_name['und'][0]['value'] . ' ' . $account->field_customer_surname['und'][0]['value'] ?>
          </h3>

          <p id='customer_age'><?php echo t('Age:') . $account->field_age['und'][0]['value']; ?>
          </p>

          <p
            id='customer_goal'><?php echo t('Goals:')?><?php echo empty($account->field_customer_goals['und'][0]['value']) ? t('N/A')
            : $account->field_customer_goals['und'][0]['value']; ?>
          </p>

          <p
            id='customer_sports'><?php echo t('Sports:')?><?php echo empty($account->field_customer_sports['und'][0]['value']) ? t('N/A')
            : $account->field_customer_sports['und'][0]['value']; ?></p>

          <p
            id='customer_interested'><?php echo t('Interested In:')?><?php echo empty($account->field_customer_interest['und'][0]['value'])
            ? t('N/A') : $account->field_customer_interest['und'][0]['value']; ?></p>

          <p
            id='customer_info'><?php echo t('Info:') . '<br />'?><?php echo empty($account->field_info['und'][0]['value']) ? t('N/A')
            : $account->field_info['und'][0]['value']; ?></p>
          <input type="hidden" id="customer_name_hidden"
                 value="<?php echo $account->field_customer_name['und'][0]['value'];?>">
          <input type="hidden" id="customer_surname_hidden"
                 value="<?php echo $account->field_customer_surname['und'][0]['value'];?>">
          <?php if (arg(0) != 'member' && !is_numeric(arg(1))): ?>
          <a href="javascript:;" id="btn_edit_account_info"></a>
          <?php endif;?>

        </div>
      </div>
      <!-- end banner-content -->
      <div id="banner-train">
        <div id="banner-quick-train">
          <h3><?php echo t('Search for Trainers / Videos') ?></h3>
          <?php echo render(drupal_get_form('tvn_trainer_video_search_form')); ?>
        </div>
        <!-- banner-quick-train -->
        <div id="banner-trainers-online">
          <ul>
            <li><a href="#" title="">Tom Jones</a><span>online now</span></li>
            <li><a href="#" title="">Alan Smith</a><span>online now</span></li>
            <li><a href="#" title="">Bradley Finley</a><span>online now</span></li>
          </ul>
          <div class="clear"></div>
        </div>
        <!-- banner-trainers-online -->
      </div>
      <!-- banner-train -->
    </div>
    <div class="clear"></div>
    <!-- end clear -->
  </div>
  </div>
  <div id="customer_profile_body">
    <div class="customer_profile_left">
      <div class="my_photo_video">
        <div id="my_photo">
          <div
            class="title"><?php echo (arg(0) == 'member') ? $account->field_customer_name['und'][0]['value'] . '\'s Photo' : 'My Photo';?></div>
          <div class="box_content">
            <?php if ($data['my_image']->rowCount() > 0): ?>
            <?php foreach ($data['my_image'] as $img): ?>
              <img src="<?php echo image_style_url('thumbnail', $img->uri) ?>">
              <?php endforeach; ?>
            <?php else: ?>
                <div id="image_not_exists">Account has not any video</div>
            <?php endif;?>
            <div style="clear:both"
            ;?>
          </div>
        </div>
      </div>
      <div id="my_video">
        <div
          class="title"><?php echo (arg(0) == 'member') ? $account->field_customer_name['und'][0]['value'] . '\'s Video' : 'My Video';?></div>
        <div class="box_content">
          <?php if ($data['my_video']->rowCount() > 0): ?>
          <?php foreach ($data['my_video'] as $video): ?>
            <a href="<?php echo base_path() . 'node/' . $video->nid; ?>" title="<?php echo $video->title ?>">
              <span><?php echo t('View Video'); ?></span>
              <img src="<?php echo image_style_url('pre_recorded_video_thumb', $video->uri) ?>"
                   alt="<?php echo $video->title ?>"/>
            </a>
            <?php endforeach; ?>
          <?php else: ?>
          <div id="video_not_exists">Account has not any video</div>
          <?php endif;?>
          <div style="clear:both"
          ;?>
        </div>
      </div>
    </div>
  </div>
  <div id='profile_following'>
    <div class="title">Following</div>
    <ul>
      <?php foreach ($data['trainer_following'] as $list): ?>
      <li><img src="<?php echo($list->uri != Null) ? image_style_url('avartar', $customer->uri)
        : base_path() . 'sites/all/modules/tvn_modules/tvn_common/images/no_avatar2.jpg'; ?>">

        <p><a href="javasricp:;"> <?php echo $list->name;?></a></p></li>
      <?php endforeach;?>

    </ul>
    <div style="clear:both;"></div>
  </div>

  <div id='profile_adverts'>

  </div>
    </div>
    <div class="customer_profile_right">
      <div class="pre_recorded_video">
        <h3><?php echo t("Pre Recorded Videos");?></h3>
        <?php if (!empty($data['pre-recorded-video'])) { ?>
        <ul id="latest-jcarousel_1" class="jcarousel-skin-tango">
          <?php foreach ($data['pre-recorded-video'] as $pre_video) { ?>
          <li class="member-jcarousel">
            <a href="<?php echo $pre_video->alias ?>" title="<?php echo $pre_video->title ?>">
              <span><?php echo t('View Video'); ?></span>
              <img src="<?php echo image_style_url('pre_recorded_video_thumb', $pre_video->uri) ?>"
                   width="130"
                   height="100" alt="<?php echo $pre_video->title ?>"/>
            </a>
          </li>
          <?php } ?>
        </ul>
        <?php } ?>
        <div style="clear:both;"></div>
      </div>

      <div class="pre_recorded_video interested_video">
        <h3><?php echo t("Videos you may be interested in");?></h3>
        <?php if (!empty($data['interested-recorded-video'])) { ?>
        <ul id="latest-jcarousel_2" class="jcarousel-skin-tango">
          <?php foreach ($data['interested-recorded-video'] as $interested_video) { ?>
          <li class="member-jcarousel">
            <a href="<?php echo $interested_video->alias ?>" title="<?php echo $interested_video->title ?>">
              <span><?php echo t('View Video'); ?></span>
              <img src="<?php echo image_style_url('pre_recorded_video_thumb', $interested_video->uri) ?>"
                   width="130"
                   height="100" alt="<?php echo $interested_video->title ?>"/>
            </a>
          </li>
          <?php } ?>
        </ul>
        <?php } ?>
        <div style="clear:both;"></div>
      </div>

      <div class="box_private_personal">
        <div class="box_wall">
          <h1>Personal Wall / News Feed</h1>

          <div class="box_personal_wall">
            <?php foreach ($data['news_feed'] as $feed): ?>
            <div class="items-box">
              <span><?php echo date('D jS', strtotime($feed->created));?></span>

              <p><?php echo $feed->body;?></p>

              <div style="clear:both"></div>
            </div>
            <hr>
            <?php endforeach;?>

          </div>
        </div>
        <div class="box_feeds">
          <h1>Following News Feeds</h1>

          <div class="content_following_news_feed">
            <img src="" alt="">

            <p><span>Andy Jones</span>Wisi dui, vivamus vehicula urna tortar aenean id, nunc interdum, elementum
              eu
              facillisi dolor volutpat, phasellus urna placeat</p>

            <div style="clear:both"></div>
          </div>
        </div>
      </div>
    </div>
</div>
<?php } else { ?>
<h3>User is not exists</h3>
<?php } ?>
</div>
<div id="dialog_box">

</div>

